<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table id="table">
        <tr>
          <td>单元格1-1</td>
          <td>单元格1-2</td>
          <td>单元格1-3</td>
        </tr>
        <tr>
          <td>单元格2-1</td>
          <td>单元格2-2</td>
          <td>单元格2-3</td>
        </tr>
        <tr>
          <td>单元格3-1</td>
          <td>单元格3-2</td>
          <td>单元格3-3</td>
        </tr>
      </table>

      <script>
        // 点击某个td元素，可以将该td元素的文本内容输出到控制台

        // 1.获取元素
        const table = document.querySelector('#table')

        const tds = document.querySelectorAll('Td')
        tds.forEach(function (item) {
            item.addEventListener('click', function (e) {
                // console.log(e);
                console.log (e.target.innerHTML)
            })
        })
      </script>
</body>
</html>